package chouxiang类;

public class computer {
	public void powerOn() {
		System.out.println("打开笔记本电脑");
	}
	public void powerOff() {
		System.out.println("关闭笔记本电脑");
	}
	public void useDevice (iusb usb) {
		usb.openDevice();
		if(usb instanceof mouse) {
			mouse mouse1=(mouse ) usb;
			mouse1.click();
		}else if(usb instanceof  keyboard) {
			keyboard keyboard1=(keyboard) usb;
			keyboard1.keypress();
		}
		usb.closeDevice();
	}

	public static void main(String[] args) {
		computer computer1=new computer();
		computer1.powerOn();

		computer1.useDevice(new mouse());
		computer1.useDevice(new keyboard());
		computer1.powerOff();
	}
}
